from django.contrib.auth.models import AbstractUser
from django.db import models

class User(AbstractUser):
    """用户模型"""
    nickname = models.CharField(max_length=50, blank=True, verbose_name='昵称')
    avatar = models.ImageField(
        upload_to='avatars/',
        null=True,
        blank=True,
        verbose_name='头像'
    )
    
    # 用户类型
    USER_TYPES = [
        ('player', '玩家'),
        ('gm', '游戏主持人'),
        ('admin', '管理员'),
    ]
    user_type = models.CharField(
        max_length=20,
        choices=USER_TYPES,
        default='player',
        verbose_name='用户类型'
    )
    
    # 用户状态
    is_online = models.BooleanField(default=False, verbose_name='是否在线')
    last_activity = models.DateTimeField(
        auto_now=True,
        verbose_name='最后活动时间'
    )
    
    class Meta:
        verbose_name = '用户'
        verbose_name_plural = '用户'
        
    def __str__(self):
        return self.nickname or self.username
